Skip to main content

Global Shadow Mask Default Dx9 Hwsm

(global_shadow_mask:default:DX9_HWSM, 0x59f8b51b63180f82)

This template is referenced 1 time by global_shadow_mask.

Technique ambient

Render States

More info can be found on the Direct3D Docs

enum D3DRENDERSTATETYPE {
D3DRS_ZENABLE = 1,
D3DRS_ZFUNC = 7,
D3DRS_ZWRITEENABLE = 0,
D3DRS_ALPHABLENDENABLE = 0,
D3DRS_CULLMODE = 1,
D3DRS_COLORWRITEENABLE = 8,
D3DRS_COLORWRITEENABLE1 = 15,
D3DRS_COLORWRITEENABLE2 = 15,
D3DRS_STENCILENABLE = 0,
D3DRS_STENCILFUNC = 1,
D3DRS_STENCILFAIL = 1,
D3DRS_STENCILMASK = 0,
D3DRS_STENCILPASS = 1,
D3DRS_STENCILREF = 0,
D3DRS_STENCILWRITEMASK = 0,
D3DRS_STENCILZFAIL = 1,
D3DRS_DEPTHBIAS = 0,
D3DRS_SLOPESCALEDEPTHBIAS = 0,
D3DRS_FOGENABLE = 0,
D3DRS_SPECULARENABLE = 0,
D3DRS_ADAPTIVETESS_X = 0,
D3DRS_ADAPTIVETESS_Z = 0,
D3DRS_ADAPTIVETESS_W = 0,
D3DRS_SRGBWRITEENABLE = 0,
D3DRS_SEPARATEALPHABLENDENABLE = 0,
D3DRS_ALPHATESTENABLE = 0,
};

Sampler States

More info can be found on the Direct3D Docs

Sampler 0

enum D3DSAMPLERSTATETYPE {
D3DSAMP_MIPMAPLODBIAS = 827606343,
D3DSAMP_SRGBTEXTURE = 0,
D3DSAMP_ADDRESSU = 3,
D3DSAMP_ADDRESSV = 3,
D3DSAMP_MAGFILTER = 1,
D3DSAMP_MINFILTER = 1,
D3DSAMP_MIPFILTER = 1,
};

Sampler 1

enum D3DSAMPLERSTATETYPE {
D3DSAMP_MIPMAPLODBIAS = 827606343,
D3DSAMP_SRGBTEXTURE = 0,
D3DSAMP_ADDRESSU = 3,
D3DSAMP_ADDRESSV = 3,
D3DSAMP_MAGFILTER = 2,
D3DSAMP_MINFILTER = 2,
D3DSAMP_MIPFILTER = 2,
};

Shaders

Vertex Shader

column_major float4x4 camera_inv_view_matrix : register(vs_3_0, c4);
float3 camera_unprojection : register(vs_3_0, c7);
float ref_depth_clip_space : register(vs_3_0, c8);
column_major float4x4 view_proj_matrix : register(vs_3_0, c0);
struct VertexMain_Input
{
float4 position : POSITION;
float4 texcoord : TEXCOORD;
};

struct VertexMain_Output
{
float4 position : POSITION;
float2 texcoord : TEXCOORD;
float3 texcoord1 : TEXCOORD1;
};

VertexMain_Output VertexMain(VertexMain_Input i)
{
VertexMain_Output o;
float2 temp0;
float3 temp1;
// def c9, 1, 0, 0, 0
// dcl_position v0
// dcl_texcoord v1
// dcl_position o0
// dcl_texcoord o1.xy
// dcl_texcoord1 o2.xyz
// dp4 o0.w, v0, c3
o.position.w = dot(i.position, (view_proj_matrix._m03_m13_m23_m33));
// dp4 r0.x, v0, c0
temp0.x = dot(i.position, (view_proj_matrix._m00_m10_m20_m30));
// dp4 r0.y, v0, c1
temp0.y = dot(i.position, (view_proj_matrix._m01_m11_m21_m31));
// mul r1.xy, r0, c7
temp1.xy = temp0.xy * camera_unprojection.xy;
// mov o0.xy, r0
o.position.xy = temp0.xy;
// mov r1.z, c9.x
temp1.z = float1(1);
// dp3 o2.x, r1, c4
o.texcoord1.x = dot(temp1.xyz, (camera_inv_view_matrix._m00_m10_m20_m30).xyz);
// dp3 o2.y, r1, c5
o.texcoord1.y = dot(temp1.xyz, (camera_inv_view_matrix._m01_m11_m21_m31).xyz);
// dp3 o2.z, r1, c6
o.texcoord1.z = dot(temp1.xyz, (camera_inv_view_matrix._m02_m12_m22_m32).xyz);
// mov o0.z, c8.x
o.position.z = ref_depth_clip_space.x;
// mov o1.xy, v1
o.texcoord = i.texcoord;
//

return o;
}

Decompiled by DXDecompiler.

Pixel Shader

column_major float4x4 camera_world_matrix : register(ps_3_0, c12);
sampler2D depth : register(ps_3_0, s0);
sampler2D displacement_texture : register(ps_3_0, s1);
float3 displacement_texture_size : register(ps_3_0, c17);
column_major float4x4 global_shadow_projection[3] : register(ps_3_0, c0);
float3 ref_shadow_slice_depths : register(ps_3_0, c15);
float3 ref_shadow_slice_overlap : register(ps_3_0, c16);
struct PixelMain_Input
{
float2 texcoord : TEXCOORD;
float3 texcoord1 : TEXCOORD1;
};

float4 PixelMain(PixelMain_Input i) : COLOR
{
float4 out_color;
float4 temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7, temp8, temp9;
// def c18, 0, 1, 2, 0.5
// def c19, 0.2, 0, 0, 0
// dcl_texcoord v0.xy
// dcl_texcoord1 v1.xyz
// dcl_2d s0
// dcl_2d s1
// texld r0, v0, s0
temp0 = tex2D(depth, i.texcoord.xy);
// add r0.yz, -r0.x, c15.xyxw
temp0.yz = -temp0.xx + ref_shadow_slice_depths.yx;
// cmp r0.z, r0.z, c18.x, c18.y
temp0.z = (temp0.z >= 0) ? float1(0) : float1(1);
// cmp r0.y, r0.y, r0.z, c18.z
temp0.y = (temp0.y >= 0) ? temp0.z : float1(2);
// add r1.xyz, r0.y, -c18
temp1.xyz = temp0.yyy + float3(-0, -1, -2);
// mov r2.x, c18.x
temp2.x = float1(0);
// cmp r3, -r1_abs.x, c2, r2.x
temp3 = (-abs(temp1).x >= 0) ? (global_shadow_projection[0]._m02_m12_m22_m32) : temp2.x;
// cmp r3, -r1_abs.y, c6, r3
temp3 = (-abs(temp1).y >= 0) ? (global_shadow_projection[1]._m02_m12_m22_m32) : temp3;
// cmp r3, -r1_abs.z, c10, r3
temp3 = (-abs(temp1).z >= 0) ? (global_shadow_projection[2]._m02_m12_m22_m32) : temp3;
// mov r4.w, c18.y
temp4.w = float1(1);
// mad r4.x, v1.x, r0.x, c12.w
temp4.x = i.texcoord1.x * temp0.x + (camera_world_matrix._m00_m10_m20_m30).w;
// mad r4.y, v1.y, r0.x, c13.w
temp4.y = i.texcoord1.y * temp0.x + (camera_world_matrix._m01_m11_m21_m31).w;
// mad r4.z, v1.z, r0.x, c14.w
temp4.z = i.texcoord1.z * temp0.x + (camera_world_matrix._m02_m12_m22_m32).w;
// dp4 r3.z, r4, r3
temp3.z = dot(temp4, temp3);
// cmp r5, -r1_abs.x, c3, r2.x
temp5 = (-abs(temp1).x >= 0) ? (global_shadow_projection[0]._m03_m13_m23_m33) : temp2.x;
// cmp r5, -r1_abs.y, c7, r5
temp5 = (-abs(temp1).y >= 0) ? (global_shadow_projection[1]._m03_m13_m23_m33) : temp5;
// cmp r5, -r1_abs.z, c11, r5
temp5 = (-abs(temp1).z >= 0) ? (global_shadow_projection[2]._m03_m13_m23_m33) : temp5;
// dp4 r0.z, r4, r5
temp0.z = dot(temp4, temp5);
// rcp r0.z, r0.z
temp0.z = 1.0f / temp0.z;
// cmp r5, -r1_abs.x, c0, r2.x
temp5 = (-abs(temp1).x >= 0) ? (global_shadow_projection[0]._m00_m10_m20_m30) : temp2.x;
// cmp r5, -r1_abs.y, c4, r5
temp5 = (-abs(temp1).y >= 0) ? (global_shadow_projection[1]._m00_m10_m20_m30) : temp5;
// cmp r5, -r1_abs.z, c8, r5
temp5 = (-abs(temp1).z >= 0) ? (global_shadow_projection[2]._m00_m10_m20_m30) : temp5;
// dp4 r3.x, r4, r5
temp3.x = dot(temp4, temp5);
// cmp r5, -r1_abs.x, c1, r2.x
temp5 = (-abs(temp1).x >= 0) ? (global_shadow_projection[0]._m01_m11_m21_m31) : temp2.x;
// cmp r5, -r1_abs.y, c5, r5
temp5 = (-abs(temp1).y >= 0) ? (global_shadow_projection[1]._m01_m11_m21_m31) : temp5;
// cmp r1, -r1_abs.z, c9, r5
temp1 = (-abs(temp1).z >= 0) ? (global_shadow_projection[2]._m01_m11_m21_m31) : temp5;
// dp4 r3.y, r4, r1
temp3.y = dot(temp4, temp1);
// mul r1.xyz, r0.z, r3
temp1.xyz = temp0.zzz * temp3.xyz;
// mad r5.zw, r1.z, c18.xyyx, c18.xyxy
temp5.zw = temp1.zz * float2(1, 0) + float2(0, 1);
// rcp r6.x, c17.x
temp6.x = 1.0f / displacement_texture_size.x;
// rcp r6.y, c17.y
temp6.y = 1.0f / displacement_texture_size.y;
// mul r2.yz, r6.xxyw, c18.w
temp2.yz = temp6.xy * float2(0.5, 0.5);
// mad r5.xy, r3, r0.z, -r2.yzzw
temp5.xy = temp3.xy * temp0.zz + -temp2.yz;
// mov r6.xzw, r5
temp6.xzw = temp5.xzw;
// mad r7.xy, r3, r0.z, r2.yzzw
temp7.xy = temp3.xy * temp0.zz + temp2.yz;
// mov r6.y, r7.y
temp6.y = temp7.y;
// texld r8, r6, s1
temp8 = tex2D(displacement_texture, temp6.xy);
// mov r7.yzw, r5
temp7.yzw = temp5.yzw;
// texld r5, r5, s1
temp5 = tex2D(displacement_texture, temp5.xy);
// texld r9, r7, s1
temp9 = tex2D(displacement_texture, temp7.xy);
// mov r6.xzw, r7
temp6.xzw = temp7.xzw;
// add r0.w, r8.x, -r9.x
temp0.w = temp8.x + -temp9.x;
// texld r7, r6, s1
temp7 = tex2D(displacement_texture, temp6.xy);
// add r2.w, -r5.x, r7.x
temp2.w = -temp5.x + temp7.x;
// add r5.x, r0.w, r2.w
temp5.x = temp0.w + temp2.w;
// add r5.y, r0.w, -r2.w
temp5.y = temp0.w + -temp2.w;
// mul r3.zw, r2.xyyz, r5.xyxy
temp3.zw = temp2.yz * temp5.xy;
// add r3.zw, r3, r3
temp3.zw = temp3.zw + temp3.zw;
// mad r6.xy, r3, r0.z, -r3.zwzw
temp6.xy = temp3.xy * temp0.zz + -temp3.zw;
// mad r3.xy, r3, r0.z, r3.zwzw
temp3.xy = temp3.xy * temp0.zz + temp3.zw;
// texld r5, r6, s1
temp5 = tex2D(displacement_texture, temp6.xy);
// mov r3.zw, r6
temp3.zw = temp6.zw;
// texld r3, r3, s1
temp3 = tex2D(displacement_texture, temp3.xy);
// mov r1.w, c18.y
temp1.w = float1(1);
// texld r1, r1, s1
temp1 = tex2D(displacement_texture, temp1.xy);
// mad r0.z, r5.x, c18.z, r1.x
temp0.z = temp5.x * float1(2) + temp1.x;
// mad r0.z, r3.x, c18.z, r0.z
temp0.z = temp3.x * float1(2) + temp0.z;
// mov r1.xyz, c15
temp1.xyz = ref_shadow_slice_depths.xyz;
// add r1.xyz, r1.yxzw, -c16.yxzw
temp1.xyz = temp1.yxz + -ref_shadow_slice_overlap.yxz;
// add r1.xyw, -r0.x, r1.xyzz
temp1.xyw = -temp0.xxx + temp1.xyz;
// add r0.w, r0.x, -r1.z
temp0.w = temp0.x + -temp1.z;
// cmp r1.y, r1.y, c18.x, c18.y
temp1.y = (temp1.y >= 0) ? float1(0) : float1(1);
// cmp r1.x, r1.x, r1.y, c18.z
temp1.x = (temp1.x >= 0) ? temp1.y : float1(2);
// add r3.xyz, r1.x, -c18
temp3.xyz = temp1.xxx + float3(-0, -1, -2);
// cmp r5, -r3_abs.x, c2, r2.x
temp5 = (-abs(temp3).x >= 0) ? (global_shadow_projection[0]._m02_m12_m22_m32) : temp2.x;
// cmp r5, -r3_abs.y, c6, r5
temp5 = (-abs(temp3).y >= 0) ? (global_shadow_projection[1]._m02_m12_m22_m32) : temp5;
// cmp r5, -r3_abs.z, c10, r5
temp5 = (-abs(temp3).z >= 0) ? (global_shadow_projection[2]._m02_m12_m22_m32) : temp5;
// dp4 r5.z, r4, r5
temp5.z = dot(temp4, temp5);
// cmp r6, -r3_abs.x, c3, r2.x
temp6 = (-abs(temp3).x >= 0) ? (global_shadow_projection[0]._m03_m13_m23_m33) : temp2.x;
// cmp r6, -r3_abs.y, c7, r6
temp6 = (-abs(temp3).y >= 0) ? (global_shadow_projection[1]._m03_m13_m23_m33) : temp6;
// cmp r6, -r3_abs.z, c11, r6
temp6 = (-abs(temp3).z >= 0) ? (global_shadow_projection[2]._m03_m13_m23_m33) : temp6;
// dp4 r1.y, r4, r6
temp1.y = dot(temp4, temp6);
// rcp r1.y, r1.y
temp1.y = 1.0f / temp1.y;
// cmp r6, -r3_abs.x, c0, r2.x
temp6 = (-abs(temp3).x >= 0) ? (global_shadow_projection[0]._m00_m10_m20_m30) : temp2.x;
// cmp r6, -r3_abs.y, c4, r6
temp6 = (-abs(temp3).y >= 0) ? (global_shadow_projection[1]._m00_m10_m20_m30) : temp6;
// cmp r6, -r3_abs.z, c8, r6
temp6 = (-abs(temp3).z >= 0) ? (global_shadow_projection[2]._m00_m10_m20_m30) : temp6;
// dp4 r5.x, r4, r6
temp5.x = dot(temp4, temp6);
// cmp r6, -r3_abs.x, c1, r2.x
temp6 = (-abs(temp3).x >= 0) ? (global_shadow_projection[0]._m01_m11_m21_m31) : temp2.x;
// cmp r6, -r3_abs.y, c5, r6
temp6 = (-abs(temp3).y >= 0) ? (global_shadow_projection[1]._m01_m11_m21_m31) : temp6;
// cmp r3, -r3_abs.z, c9, r6
temp3 = (-abs(temp3).z >= 0) ? (global_shadow_projection[2]._m01_m11_m21_m31) : temp6;
// dp4 r5.y, r4, r3
temp5.y = dot(temp4, temp3);
// mul r3.xyz, r1.y, r5
temp3.xyz = temp1.yyy * temp5.xyz;
// mad r4.zw, r3.z, c18.xyyx, c18.xyxy
temp4.zw = temp3.zz * float2(1, 0) + float2(0, 1);
// mad r4.xy, r5, r1.y, -r2.yzzw
temp4.xy = temp5.xy * temp1.yy + -temp2.yz;
// mov r6.xzw, r4
temp6.xzw = temp4.xzw;
// mad r7.xy, r5, r1.y, r2.yzzw
temp7.xy = temp5.xy * temp1.yy + temp2.yz;
// mov r6.y, r7.y
temp6.y = temp7.y;
// texld r8, r6, s1
temp8 = tex2D(displacement_texture, temp6.xy);
// mov r7.yzw, r4
temp7.yzw = temp4.yzw;
// texld r4, r4, s1
temp4 = tex2D(displacement_texture, temp4.xy);
// texld r9, r7, s1
temp9 = tex2D(displacement_texture, temp7.xy);
// mov r6.xzw, r7
temp6.xzw = temp7.xzw;
// add r1.z, r8.x, -r9.x
temp1.z = temp8.x + -temp9.x;
// texld r7, r6, s1
temp7 = tex2D(displacement_texture, temp6.xy);
// add r2.w, -r4.x, r7.x
temp2.w = -temp4.x + temp7.x;
// add r4.x, r1.z, r2.w
temp4.x = temp1.z + temp2.w;
// add r4.y, r1.z, -r2.w
temp4.y = temp1.z + -temp2.w;
// mul r2.yz, r2, r4.xxyw
temp2.yz = temp2.yz * temp4.xy;
// add r2.yz, r2, r2
temp2.yz = temp2.yz + temp2.yz;
// mad r6.xy, r5, r1.y, -r2.yzzw
temp6.xy = temp5.xy * temp1.yy + -temp2.yz;
// mad r4.xy, r5, r1.y, r2.yzzw
temp4.xy = temp5.xy * temp1.yy + temp2.yz;
// texld r5, r6, s1
temp5 = tex2D(displacement_texture, temp6.xy);
// mov r4.zw, r6
temp4.zw = temp6.zw;
// texld r4, r4, s1
temp4 = tex2D(displacement_texture, temp4.xy);
// mov r3.w, c18.y
temp3.w = float1(1);
// texld r3, r3, s1
temp3 = tex2D(displacement_texture, temp3.xy);
// mad r1.y, r5.x, c18.z, r3.x
temp1.y = temp5.x * float1(2) + temp3.x;
// mad r1.y, r4.x, c18.z, r1.y
temp1.y = temp4.x * float1(2) + temp1.y;
// mul r1.y, r1.y, c19.x
temp1.y = temp1.y * float1(0.2);
// mad r1.z, r0.z, c19.x, -r1.y
temp1.z = temp0.z * float1(0.2) + -temp1.y;
// mul r0.z, r0.z, c19.x
temp0.z = temp0.z * float1(0.2);
// add r2.yz, r1.x, -c18
temp2.yz = temp1.xx + float2(-1, -2);
// add r0.y, r0.y, -r1.x
temp0.y = temp0.y + -temp1.x;
// cmp r2.yz, -r2_abs, c18.y, c18.x
temp2.yz = (-abs(temp2).yz >= 0) ? float2(1, 1) : float2(0, 0);
// dp2add r0.x, c15, r2.yzzw, -r0.x
temp0.x = dot(ref_shadow_slice_depths.xy, temp2.yz) + -temp0.x;
// dp2add r1.x, c16, r2.yzzw, r2.x
temp1.x = dot(ref_shadow_slice_overlap.xy, temp2.yz) + temp2.x;
// rcp r1.x, r1.x
temp1.x = 1.0f / temp1.x;
// mul r0.x, r0.x, r1.x
temp0.x = temp0.x * temp1.x;
// mad r0.x, r0.x, r1.z, r1.y
temp0.x = temp0.x * temp1.z + temp1.y;
// cmp r0.x, -r0_abs.y, r0.z, r0.x
temp0.x = (-abs(temp0).y >= 0) ? temp0.z : temp0.x;
// rcp r0.y, c16.z
temp0.y = 1.0f / ref_shadow_slice_overlap.z;
// mul_sat r0.y, r0.y, r0.w
temp0.y = saturate(temp0.y * temp0.w);
// add_sat r0.y, r0.y, r0.x
temp0.y = saturate(temp0.y + temp0.x);
// cmp oC0, r1.w, r0.x, r0.y
out_color = (temp1.w >= 0) ? temp0.x : temp0.y;
//

return out_color;
}

Decompiled by DXDecompiler.